package com.zhujie;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@StudentAnntation(className = "com.zhujie.Student",methodName = "eat")
public class AnntationReflect {
    public static void main(String[] args) {
        StudentAnntation annotation = AnntationReflect.class.getAnnotation(StudentAnntation.class);
        String className = annotation.className();
        String methodName = annotation.methodName();

        Class<?> aClass = null;
        try {
            aClass = Class.forName(className);
            Object o = aClass.newInstance();
            Method method = aClass.getMethod(methodName);
            method.invoke(o);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}